package model.solver;

/**
 * Status of a solver execution.
 * 
 * @author GRONOWSKI Stephane svan001@aol.com
 * 
 *         igsat 2010
 * 
 */
public enum SolverResultStatus {
	TIMEOUT_REACHED ("Problem : timeout has been reached", "timeout_reached"), SATISFIABLE ("SATISFIABLE : the CNF is satisfiable !",
			"satisfiable"), PROBLEM ("Error : a probleme occured during the operation", "problem"), UNSATISFIABLE (
			"The CNF is unsatisfiable !", "unsatisfiable"), STOP ("The execution has been stop", "stop"), UNKNOWN (
			"The state of the cnf is unknown", "unknown");


	private String	description;
	private String	xmlValue;


	private SolverResultStatus(String description, String xmlValue) {
		this.description = description;
		this.xmlValue = xmlValue;
	}

	/**
	 * Return a description of the status.
	 * 
	 * @return a description of the status.
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * Return the xmlValue, value that is supposed to written in the xml exportation.
	 * 
	 * @return the xmlValue
	 */
	public String getXmlValue() {
		return xmlValue;
	}

	/**
	 * Return the {@link SolverResultStatus} associate to a value find in a XML exportation.
	 * 
	 * @param value
	 *            xml value
	 * @return the associate {@link SolverResultStatus}
	 */
	public static SolverResultStatus getValueFromXML(String value) {
		for (SolverResultStatus stat : values())
			if (stat.getXmlValue().equals(value))
				return stat;
		return null;
	}

}
